package com.qmx.launcher.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.qmx.launcher.R;
import com.qmx.launcher.activity.base.BaseActivity;

import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;

public class MemberDetailsActivity extends BaseActivity implements View.OnClickListener {

    private CircleImageView iv_avatar;
    private TextView tv_contact_name, tv_contact_tel, tv_contact_email, tv_contact_department, tv_contact_post;
    private Button btn_video_call, btn_call_meeting_room;

    private SpannableString contact_tel, contact_email, contact_department, contact_post;

    private Intent intent;
    private Context mContext;
    private String contact_name;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_member_details);
        mContext = this;
        intent = this.getIntent();
        initView();
    }

    private void initView() {
        tv_contact_name = findViewById(R.id.tv_contact_name);
        tv_contact_tel = findViewById(R.id.tv_contact_tel);
        tv_contact_email = findViewById(R.id.tv_contact_email);
        tv_contact_department = findViewById(R.id.tv_contact_department);
        tv_contact_post = findViewById(R.id.tv_contact_post);

        contact_tel = new SpannableString("电话：" + intent.getStringExtra("tel"));
        contact_tel.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.edit_bg)), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        contact_tel.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.white)), 3, contact_tel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        contact_email = new SpannableString("邮箱：" + intent.getStringExtra("email"));
        contact_email.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.edit_bg)), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        contact_email.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.white)), 3, contact_email.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        contact_department = new SpannableString("部门：" + intent.getStringExtra("department"));
        contact_department.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.edit_bg)), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        contact_department.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.white)), 3, contact_department.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        contact_post = new SpannableString("职务：" + intent.getStringExtra("post"));
        contact_post.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.edit_bg)), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        contact_post.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.white)), 3, contact_post.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        tv_contact_name.setText(contact_name);
        tv_contact_tel.setText(contact_tel);
        tv_contact_email.setText(contact_email);
        tv_contact_department.setText(contact_department);
        tv_contact_post.setText(contact_post);

        btn_video_call = findViewById(R.id.btn_video_call);
        btn_video_call.setOnClickListener(this);
        btn_call_meeting_room = findViewById(R.id.btn_call_meeting_room);
        btn_call_meeting_room.setOnClickListener(this);

        intent = new Intent();

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_video_call:
                intent.setClass(mContext, CallContactActivity.class);
                break;
            case R.id.btn_call_meeting_room:
                intent.setClass(mContext, CallContactActivity.class);
                break;
        }
        startActivity(intent);
    }
}
